package cn.school.student.dao;

import cn.school.student.entity.StudentTrajectory;
import cn.school.student.entity.vo.StudentTrajectoryExcel;
import cn.school.student.param.StudentTrajectoryPageParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface StudentTrajectoryMapper extends BaseMapper<StudentTrajectory> {

    void insertBatch(@Param("trajectoryList") List<StudentTrajectory> trajectoryList);

    int findPageCount(@Param("query")StudentTrajectoryPageParam query);

    List<StudentTrajectory> findPageList(@Param("startNum")int startNum,
                                           @Param("query")StudentTrajectoryPageParam query);

    int teacherFindPageListCount(@Param("query")StudentTrajectoryPageParam query);

    List<StudentTrajectory> teacherFindPageList(@Param("startNum")int startNum,
                                                @Param("query")StudentTrajectoryPageParam query);

    List<StudentTrajectory> getStudentTrajectoryByClassIdAndAttendanceDate(@Param("classId") Long classId,@Param("attendanceDate") String attendanceDate);

    /**
     * 获取学生最后一次打卡时间
     * @param studentId 学生ID
     * @param attendanceDate 考勤日期
     * @param type 考勤类型
     * @return
     */
    Date getStudentLastAttendanceTime(@Param("studentId") Long studentId, @Param("attendanceDate") String attendanceDate,@Param("type") int type);

    /**
     * 导出学生轨迹数据
     * @param query
     * @return
     */
    List<StudentTrajectoryExcel> exportTrajectory(@Param("query")StudentTrajectoryPageParam query);

    /**
     * 根据当前时间点查询是否数据已存在
     * 判断的时间格式为yyyy-MM-dd HH:mm
     * 即判断同一分钟内是否存在同记录
     * @param studentId 学生表主键ID
     * @param date 格式为yyyy-MM-dd HH:mm或yyyy-MM-dd HH:mm:ss
     * @return
     */
    List<StudentTrajectory> isExistInMin(@Param("studentId")Long studentId,
                                         @Param("date")String date);

    int updateSnapByStuIdAndFaceTime(@Param("studentId")String studentId,
                                     @Param("faceTime")String faceTime,
                                     @Param("snapFtpUrl")String snapFtpUrl);
}
